package kaizone.haining.chaobohui.widget;

import kaizone.haining.chaobohui.util.ImageFetcher;
import android.app.Activity;
import android.content.Context;
import android.graphics.Rect;
import android.util.DisplayMetrics;
import android.view.ViewTreeObserver;
import android.view.ViewTreeObserver.OnGlobalLayoutListener;
import android.widget.ImageView;
import android.widget.PopupWindow;

public class ImageWindow extends PopupWindow{
	
	private Activity mActivity;
	
	private DragImageView mImageView;
	
	public ImageWindow(Activity activity) {
		super(activity);
		mActivity = activity;
		setOutsideTouchable(true);
		initRange();
		initContent();
	}
	
	private void initRange(){
        DisplayMetrics dm = new DisplayMetrics();
        mActivity.getWindowManager().getDefaultDisplay().getMetrics(dm);
        final int width = dm.widthPixels;
        final int height = width;
        setWidth(width);
        setHeight(height);
	}
	
	public void initContent(){
		mImageView = new DragImageView(mActivity);
		mImageView.setmActivity(mActivity);
//		mImageView = new ZoomImageView(mActivity);
		setContentView(mImageView);
	}
	
	public void loadImage(String imageUrl, ImageFetcher imageFetcher){
		imageFetcher.loadImage(imageUrl, mImageView);
	}

}
